(function() {
	GameQRCode = function(rpc) {
		this.rpc = rpc;
		this.is_background = false;
		this.running = false;

	};

	GameQRCode.prototype = {
		start : function(is_background) {
			this.running = true;
			this.scan_code();
		},
		stop : function() {
			this.running = false;
		},
		show : function() {
			
		},
		hide : function() {
			
		},
		scan_code : function() {
			
			window.plugins.barcodeScanner.scan(function(result) {
				rpc.send_qrcode_event(result.text, result.format, result.cancelled);
			}, function(error) {
				alert("Scan failed: " + error);
			});
			if(this.running) {
				this.scan_code();
			}
		},

	};
})();
